package cn.wolfcode.util;

import cn.wolfcode.qo.QueryObject;

public class JudgeCurrentPage {
    public static void judgeCurrentPage(int totalCount,QueryObject qo){
        // 判断用户带入的currentPage 是否操作最大页
        int pageSize = qo.getPageSize();
        int totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        // 如果用户带入的currentPage 大于totalPage,给设置为最后一页
        if (qo.getCurrentPage() > totalPage) {
            qo.setCurrentPage(totalPage); }
        //如果用户带入的currentPage 小于1, 给设置为1
        if (qo.getCurrentPage() < 1 ){
            qo.setCurrentPage(1);
        }
    }
}
